<%@ page language="java" import="java.util.*,office.BusiUtil" pageEncoding="UTF-8"%>
<%@include file="/common/jsp/taglibs-nojs-nocss.jsp"%>
<%@ page isELIgnored="false" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	String role = ((Map)session.getAttribute("user")).get("roleName").toString();
%>
<div id="pop_up_content">
	<div class="pop_up_title images_13">
		编辑请假
	</div>
	<div class="pop_up_body">
		<form id="thisForm" action="saveOrUpdateLeaveRequest.action" >
			<table border="0" cellpadding="0" cellspacing="0" width="450px">
					<tr>
				<td>
					<div class="form_input_value">
						请假人
					</div>
				</td>
				<td>
					<input type="hidden" name="form.user.id" value="<s:property value='#session.user.userId'/>" >
					<input type="hidden" name="form.id" value="<s:property value='form.id'/>" >
					<input type="hidden" name="form.department.id" value="<s:property value="#session.user.departmentId"/>">
					<input type="text" disabled="disabled" value="<s:property value='#session.user.userCname'/>" >
				</td>
			</tr>
			<tr>
				<td>
					<div class="form_input_value">
						请假开始时间
					</div>
				</td>
				<td>
					<input type="text" onclick="WdatePicker();" id="beginDate" name="form.beginDate" value="<s:property value='form.beginDate'/>" class="longinput required" >
				</td>
			</tr>
			<tr>
				<td>
					<div class="form_input_value">
						请假结束时间
					</div>
				</td>
				<td>
					<input type="text" onclick="WdatePicker();" id="endDate" name="form.endDate" onchange="return validateDate();" value="<s:property value='form.endDate'/>" class="longinput required" >
				</td>
			</tr>
			<tr>
				<td>
					<div class="form_input_value">
						请假天数
					</div>
				</td>
				<td>
					<input type="text" id="sumDay" name="form.sumDay" value="<s:property value='form.sumDay'/>" class="longinput validate_digits required" >
				</td>
			</tr>
			<tr>
				<td valign="top">
					<div class="form_input_value">
						请假原因
					</div>
				</td>
				<td>
					<textarea id='reson' name='form.reson' class='dialogy_input max_length:100 required' rows='' cols='' style='width:320px;height:100px;overflow-y:scroll;overflow-x:hidden;margin-left: 8px;'><s:property value='form.reson'/></textarea>
					<font color="red">【不能为空且字数限制100字】</font>
				</td>
			</tr>
			<tr>
				<td></td>
				<td>
					<input id="thisButton" type="button" value="提交" class="btn" onmouseout="this.className='btn'" onmousedown="this.className='btn1'" onmouseover="this.className='btn2'">
					<input type="button" value="取消" class="btn" onclick="hideDialog();" onmouseout="this.className='btn'" onmousedown="this.className='btn1'" onmouseover="this.className='btn2'">
				</td>
			</tr>
			</table>
		</form>
	</div>
</div>
<script>

	function validateDate(){
		var beginDate = document.getElementById('beginDate').value;
		var endDate = document.getElementById('endDate').value;
		if(beginDate == "" || endDate == ""){
			alert("起止时间不能为空！");
			return false;
		}
		beginDate=beginDate.replace(/-/g,"/");     
		endDate=endDate.replace(/-/g,"/");
		var   date1   =   Date.parse(beginDate);     
		var   date2   =   Date.parse(endDate);
		if(beginDate > endDate){
			alert('日期输入不合法！开始时间不能晚于结束时间。');
			document.getElementById('beginDate').value = "";
			document.getElementById('endDate').value = "";
			return false;
		}else{
			document.getElementById('sumDay').value = (date2-date1)/(60*60*1000*24)+1;
		}
	}

	/* 表单提交 */
	i.formSubmit("thisButton",	//绑定的按钮id
				  "thisForm" ,   //提交的表单id
				  function(result){
					  	var jsonMsgObj=new JsonMsgObj(result);
						var  msg=jsonMsgObj.getMessage();
					    var codeId=jsonMsgObj.getCodeid();
						var isOk=jsonMsgObj.getIsok();
						if( isOk ){
						    aerouiAlert(msg);
							hideDialog();// 隐藏窗口
							window.location.reload();
						}else{		// 如果编辑失败了
						  JsManageInfoHandleException( result , function(msg , codeId , isOk){
						  		hideDialog();// 隐藏窗口
						   });
					   }
					});
</script>